<?php
require("bases.php");

class user extends bases {

    public function __construct(){
        parent::__construct();
    }

 
    public function login(){
        try {
            $redata = array();
            $postdata = $this->spArgs();
            $obj_student = spClass("students");
            $student_rs = $obj_student->user_login($postdata["uname"], $postdata["password"]);
            $this->returnApi($redata, $student_rs);

        }catch(Exception $e){
            echo json_encode(array("data"=>"", "message"=>$e->getMessage(), "code"=>"0"));
            exit();
        }
    }

    public function checkPass(){
        try{
            $redata = array();
            $postdata = $this->spArgs();
            $obj_student = spClass("students");
            if($obj_student ->checkPass(intval($postdata['uid']),$postdata['account'], $postdata['oldPass'])){
                $redata = array("message"=>"用户密码验证成功！");
                $this->returnApi($redata);
            }else{
                throw new \think\Exception('密码输入有误，请重新输入！');
            }

        }catch(Exception $e){
            echo json_encode(array("data"=>"", "message"=>$e->getMessage(), "code"=>"0"));
            exit();
        }
    }

}